package com.hisysteTopet.hisystepet.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hisysteTopet.hisystepet.bean.IndentPet;
import com.hisysteTopet.hisystepet.bean.IndentPetLifeGoods;
import com.hisysteTopet.hisystepet.bean.UserAndPet;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

@Mapper
public interface IndentToPetLifeGoodsMapper extends BaseMapper<IndentPetLifeGoods> {


    // 查询订单
    @Select("SELECT indent_pet_life_goods.`indent_id`,indent_pet_life_goods.`sum_money`,indent_pet_life_goods.`data`,indent_pet_life_goods.`address`,indent_pet_life_goods.`payment`,indent_pet_life_goods.`price_num`,pet_life_goods.`price_name`\n" +
            "FROM indent_pet_life_goods,pet_life_goods" +
            " WHERE pet_life_goods.`price_id` = indent_pet_life_goods.`price_id` AND  username = #{username} ORDER BY  indent_pet_life_goods.`data`  DESC")
    public List<IndentPetLifeGoods> selectAllIndentByUsername(String username) ;

    // 添加订单
    @Insert("INSERT INTO indent_pet_life_goods(sum_money,`data`,address,username,price_id,price_num,price_name)" +
            " VALUE(  #{sum_money}, #{data},  #{address},#{username},#{priceId},#{priceNum},#{priceName})")
    public void insertIntend(Double sum_money, Date data, String address, String username,
                             Integer priceId, Integer priceNum,String priceName);


    // 查询购买的宠物宠物用品
//    @Select("SELECT indent_pet.`username`,indent_pet.`indent_id`,pet.`pet_name`,pet.`pet_variety` FROM indent_pet,pet\n" +
//            "WHERE pet.`pet_id` = indent_pet.`pet_id` AND username = #{username} ")
//    public List<UserAndPet> selectIntendToPet(String username);

}
